package JZOffer;

import java.util.HashMap;
import java.util.Map;

// https://leetcode.cn/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/?envType=study-plan&id=lcof&plan=lcof&plan_progress=xxj1ozje
// 数组中重复的数字
public class Day004_1 {
    public int findRepeatNumber(int[] nums) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int num : nums) {
            if (!map.containsKey(num)) {
                map.put(num, 1);
            } else {
                return num;
            }
        }
        return -1;
    }
}
